package com.neuedu.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.entity.Room;
import com.neuedu.service.RoomService;
import com.neuedu.vo.ResultCode;
import com.neuedu.vo.ResultJson;
import jakarta.annotation.Resource;
import lombok.Getter;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 * 房间表 前端控制器
 * </p>
 *
 * @author wangyu
 * @since 2025-10-14
 */
@RestController
@RequestMapping("/room")
public class RoomController {
    @Resource
    RoomService roomService;
    @GetMapping("/list")
    ResultJson<IPage<Room>> list(Integer pageNo, Integer pageSize, String roomNo) throws InterruptedException {
        return ResultJson.success(roomService.list(pageNo, pageSize, roomNo));
    }
    @PostMapping("/add")
    ResultJson<Boolean> add(Room room) {
        return ResultJson.success(roomService.save(room), "添加房间成功");
    }
    @GetMapping("/getById")
    ResultJson<Room> getById(Integer id) {
        return ResultJson.success(roomService.getById(id));
    }
    @PostMapping("/update")
    ResultJson<Boolean> update(Room room) {
        return ResultJson.success(roomService.updateById(room), "更新房间成功");
    }
    @PostMapping("/delete")
    ResultJson<Boolean> delete(Integer id) {
        return ResultJson.success(roomService.removeById(id), "删除房间成功");
    }
    @GetMapping("/get")
    ResultJson<List<Room>> list() {
        return ResultJson.success(roomService.list());
    }
    @GetMapping("/getRooms")
    ResultJson<List<Room>> getRoomNo(Integer bedId) {
        return ResultJson.success(roomService.getForOptions(bedId)) ;
    }
}
